home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TGCBOR20.ARJ / INTROPAK.COM / TSTEDIT.C < prev    next >
Text File  |  1991-04-23  |  2KB  |  107 lines

  1. /* a basic example for using the line editor */
  2.  
  3. #include "teglsys.h"
  4. #include "string.h"
  5.  
  6. /*
  7. #include <teglcond.h>
  8. #include <dos.h>
  9. #include <string.h>
  10. #include <stdlib.h>
  11. #include <tgraph.h>
  12. #include <iconsys.h>
  13. #include <fastgrph.h>
  14. #include <teglintr.h>
  15. #include <fontsys.h>
  16. #include <virtmem.h>
  17. #include <ipstacks.h>
  18. #include <teglunit.h>
  19. #include <teglmain.h>
  20. #include <errorlog.h>
  21. #include <tegledit.h>
  22. */
  23.  
  24. char mystr1[255];
  25. char mystr2[255];
  26.  
  27. imagestkptr mystrfs;
  28. msclickptr mystr1ms;
  29. msclickptr mystr2ms;
  30.  
  31. unsigned exitoption(imagestkptr fs, msclickptr ms)
  32.    {
  33.       logmessage(mystr1);
  34.       abortexit(mystr2);
  35.       return 1;
  36.    }
  37.  
  38. unsigned mydoneevent(imagestkptr fs, msclickptr ms)
  39.    {
  40.       if (visualbuttonpress(fs,ms))
  41.      dropstackimage(fs);
  42.  
  43.       return 1;
  44.    }
  45.  
  46. unsigned char strpackformat(char * txtstr)
  47.    {   unsigned char pack;
  48.        char tmpstr[255];
  49.        char *wh;
  50.  
  51.        pack = 0;
  52.        while ((wh=strchr(txtstr,' '))!=NULL) {
  53.       strcpy(tmpstr,wh+1);
  54.       strcpy(wh,tmpstr);
  55.       pack = 1;
  56.        }
  57.       return pack;
  58.    }
  59.  
  60. void createeditbox(void)
  61. {   unsigned x, y, x1, y1;
  62.     imagestkptr  fs;
  63.  
  64.     x = 100;
  65.     y = 100;
  66.     x1 = x+300;
  67.     y1 = y+100;
  68.  
  69.     strcpy(mystr1,"This is an initialized String from mystr1");
  70.     strcpy(mystr2,"This is an initialized String from mystr2");
  71.  
  72.     pushimage(x,y,x1,y1);
  73.     fs = stackptr;
  74.     mystrfs = stackptr;
  75.  
  76.     setfillpattern(gridfill,DARKGRAY);
  77.     setfillstyle(SOLID_FILL,DARKGRAY);
  78.     bevelbox(x,y,x1,y1,WHITE,LIGHTGRAY,RED,5);
  79.  
  80.     setkeyboardmouse(FALSE);
  81.     definestreditevent(fs,10,10,290,30,254,WHITE,font14,TRUE,mystr1,allchars,strpackformat,strpackformat,NULL);
  82.     mystr1ms = fs->msptr;
  83.     definestreditevent(fs,10,35,290,55,254,WHITE,cour25,TRUE,mystr2,numbersonly,strnoformat,strredisplay,NULL);
  84.     mystr2ms = fs->msptr;
  85.  
  86.     prepareforupdate(fs);
  87.     putpict(x1-60,y1-25,imageOK,BLACK);
  88.     definemouseclickarea(fs,(x1-x)-60,(y1-y)-25,(x1-x)-60+37,(y1-y)-25+14,TRUE,mydoneevent,MSCLICK);
  89.     commitupdate();
  90.  
  91.     addcapturekey(0x001C,FALSE,crclickpress);
  92.     addcapturekey(0x009C,TRUE,crclickrelease);
  93. }
  94.  
  95. void main()
  96. {
  97.    easytegl();
  98.    easyout();
  99.  
  100.    defineglobalkeyclickarea(NULL,NULL,0x082d,FALSE,exitoption);
  101.  
  102.    createeditbox();
  103.    setstredit(mystrfs,mystr2ms,1);
  104.  
  105.    teglsupervisor();
  106. }
  107.